<template>
  <div class="fiveModule">
    <div id="fiveModule" style="width: 100%;height: 100%"></div>
  </div>
</template>
<script>
import {removeStore} from "@/libs/storage";
import {getCountXctj} from "@/api/chart/chart";

export default {
  data() {
    return {
      chart: '',
      xData: ['01',  '03', '06','09','12','15','18','21','24','27','30'],
      yData: [41, 51, 55, 58, 49,50,20,30,40,45,6]
    }
  },
  methods: {
    init() {
      this.chart = echarts.init(document.getElementById('fiveModule'));

      let option = {
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: this.xData,
            // splitLine:{
            //   show:false
            // },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },

          }
        ],
        legend:{
          x:'right',
          y:'top'
        },
        yAxis: [
          {
            type: 'value',
            // splitLine:{
            //   show:false
            // },
            name: '人数',
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              lineStyle: {
                type: 'dashed'
              }
            },
          }
        ],
        series: [
          {
            name: "2024",
            smooth: true, //平滑
            type: "line",
            showSymbol: false,
            symbolSize: 10, //折线拐点大小
            data: this.yData,//纵坐标值
            itemStyle: {
              normal: {
                color: "rgb(96, 184, 255)", //图例颜色
                borderWidth: 4,
                borderColor: "rgb(96, 184, 255)",
                lineStyle: { color: "rgb(96, 184, 255)", width: 2 }
              }
            },
            areaStyle: {
              normal: {
                // 渐变填充色（线条下半部分）
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  { offset: 0, color: "rgb(96, 184, 255)" },
                  { offset: 1, color: "rgb(234, 239, 255)" }
                ])
              }
            }
          },
          // {
          //   name: "2023",
          //   smooth: true, //平滑
          //   type: "line",
          //   symbolSize: 10, //折线拐点大小
          //   showSymbol: false,
          //   data: [30, 6, 3, 1, 1],//纵坐标值
          //   itemStyle: {
          //     normal: {
          //       color: "rgb(250, 155, 43)", //图例颜色
          //       borderWidth: 2,
          //       borderColor: "rgb(250, 155, 43)",
          //       lineStyle: { color: "rgb(250, 155, 43)", width: 1 }
          //     }
          //   },
          //   areaStyle: {
          //     normal: {
          //       // 渐变填充色（线条下半部分）
          //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          //         { offset: 0, color: "rgb(250, 155, 43)" },
          //         { offset: 1, color: "rgb(245, 249, 247)" }
          //       ])
          //     }
          //   }
          // },
        ]
      }
      this.chart.setOption(option)
    },
    async getXData() {
      const res = await getCountXctj()
      if (res.success) {
        this.xData = res.result.map(e => e.xData+'K')
        this.yData = res.result.map(e => e.yData)
      }
    }
  },
  async mounted() {
    await this.getXData()
    this.init()
  }
}
</script>

<style scoped lang="less">
.fiveModule {
  width: 100%;
  height: 100%;
}
</style>